//
//  BaseTabBarController.m
//  01-UIViewHomeWork
//
//  Created by dllo on 16/7/22.
//  Copyright © 2016年 QC.L. All rights reserved.
//

#import "BaseTabBarController.h"
#import "HomePageViewController.h"
#import "MessageViewController.h"
#import "FoundViewController.h"
#import "UserViewController.h"

@interface BaseTabBarController ()

@end

@implementation BaseTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tabBar.tintColor = [UIColor whiteColor];
    
    HomePageViewController *homeVC = [[HomePageViewController alloc] init];
    [self addChildViewController:homeVC title:@"首页" image:[UIImage imageNamed:@"tabbar_homepage"] selImage:[UIImage imageNamed:@"tabbar_homepage_selected"]];
    MessageViewController *messVC = [[MessageViewController alloc] init];
    [self addChildViewController:messVC title:@"消息" image:[UIImage imageNamed:@"tabbar_message"] selImage:[UIImage imageNamed:@"tabbar_message_selected"]];
    FoundViewController *foundVC = [[FoundViewController alloc] init];
    [self addChildViewController:foundVC title:@"发现" image:[UIImage imageNamed:@"tabbar_found"] selImage:[UIImage imageNamed:@"tabbar_found_selected"]];
    UserViewController *userVC = [[UserViewController alloc] init];
    [self addChildViewController:userVC title:@"我" image:[UIImage imageNamed:@"tabbar_user"] selImage:[UIImage imageNamed:@"tabbar_user_selected"]];
}

- (void)addChildViewController:(UIViewController *)childController
                         title:(NSString *)title
                         image:(UIImage *)image
                      selImage:(UIImage *)selImage {
    UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:childController];
    navigation.tabBarItem.image = image;
    navigation.tabBarItem.selectedImage = [selImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    navigation.tabBarItem.title = title;
    [childController.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]} forState:UIControlStateNormal];
    [childController.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor colorWithRed:0.098 green:0.518 blue:0.137 alpha:1.000]} forState:UIControlStateSelected];

    [self addChildViewController:navigation];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
